<style type="text/css">
    .webNodeAdd {
    }

    .webNodeAddTree {
        display: none;
    }

    .webNodeAddTree .webNodeName {
        cursor: pointer;
    }
</style>
<@com.toolbar />
<div class="panel panel-default">
    <div class="panel-heading">栏目添加</div>
    <div class="panel-body form-horizontal webNodeAdd">
        <div class="form-group">
            <label class="col-sm-2 control-label">名　称：</label>
            <div class="col-sm-4"><input class="form-control" type="text" name="name" regx="${check.name}"/></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">父级栏目：</label>
            <div class="col-sm-8">
                <input type="hidden" name="parentId" value="${parentId}" nullable/>
                <span class="btn btn-default parentName" onClick="$('.webNodeAddTree').dialog('open')" title="点击选择父级栏目"></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">地　址：</label>
            <div class="col-sm-8"><input class="form-control" type="text" name="url" regx="${check.url}"/></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">优先级：</label>
            <div class="col-sm-2"><input class="form-control" type="number" name="index" regx="${check.index}"/></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">类　型：</label>
            <div class="col-sm-4">
            <@com.dselect id="12" name="type" null="请选择" class="form-control" />
            <#--<select name="type" class="selectmenu" style="width: 150px">
                <option value="article">内容显示</option>
                <option value="list">内容列表</option>
                <option value="url">超链接</option>
                <option value="text">单行文本</option>
                <option value="textarea">多行文本</option>
                <option value="miniEditor">简单编辑</option>
                <option value="simpleEditor">迷你编辑</option>
                <option value="fullEditor">高级编辑</option>
                <option value="file">文件</option>
                <option value="image">图片</option>
            </select>-->
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">列表显示：</label>
            <div class="col-sm-4 radio">
                <label class="radio-inline "><input type="radio" name="list" value="false">否</label>
                <label class="radio-inline "><input type="radio" name="list" value="true" checked>是</label></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">key：</label>
            <div class="col-sm-4"><input class="form-control" type="text" name="key" regx="${check.key}"/></div>
            <span class="help-block">静态化时将用于栏目URI</span>
        </div>
        <div class="webNodeAddTree">
            <div id="WEB_NODE_ROOT" pid="">
            <span class="webNodeName" title="">
                <span class="icon-libreoffice"></span>
                <span class="name" onClick="choseParent('');$('.webNodeAddTree').dialog('close')">根级栏目</span>
            </span>
            </div>
        <#list webNodes as m>
            <div id="${m._id}" pid="${m.parentId!"WEB_NODE_ROOT"}">
            <span class="webNodeName" title="${m.notes!""}">
                <span class="icon-libreoffice"></span>
                <span class="name"
                      onClick="choseParent('${m._id}');$('.webNodeAddTree').dialog('close')">${m.name}</span>
            </span>
            </div>
        </#list>
        </div>
    </div>
</div>
<script type="text/javascript">
    LC.S.choseParent = function (pid) {
        var pid = LC.S.parentId;
        if (pid == '') {
            pid = 'WEB_NODE_ROOT';
        }
        var parent = $('#' + pid);
        if (parent.length == 0) {
            parent = $('[pid=WEB_NODE_ROOT]');
        }
        $('.webNodeAdd .parentName').text(parent.find('.name:first').text());
        if (parent.attr('id') == 'WEB_NODE_ROOT') {
            $('input[name=parentId]').val('');
        } else {
            $('input[name=parentId]').val(parent.attr('id'));
        }
    }
    $(document).ready(function (e) {
        var webNodeAddTree = $('.webNodeAdd .webNodeAddTree').jTree();
        webNodeAddTree.showAll();
        LC.S.choseParent();
        dialog('.webNodeAddTree', {
            autoOpen: false,
            modal: true,
            title: "选择父级栏目"
        });
        LC.initToolbarAdd();
    });
</script>